package com.oazon.moco.bean;

import android.os.Parcel;
import android.os.Parcelable;

public class Metadata implements Parcelable{ 
	private String id;
	private String serviceID;
	private String itemID;
	private String parentID;
	private boolean restricted;
	private Res res;
	private String streamContent;
	private String radioShowMd;
	private String albumArtURI;
	private String title;
	private String objectClass;
	private String creator;
	private String album;
	private String lyricURI;
	private String artist;
	private boolean isAutoAdd;
	private String audioUrl;
	
	private boolean isFavorite;
	private boolean isRecommand = false;
	
	private boolean canAddToFavorites = true;
	
	public Metadata(){}
	
	public Metadata(Parcel source) {
		this.album = source.readString();
		this.albumArtURI= source.readString();
		this.artist= source.readString();
		this.creator= source.readString();
		this.id= source.readString();
		this.isAutoAdd= source.readByte() == 0;
		this.itemID= source.readString();
		this.lyricURI= source.readString();
		this.objectClass= source.readString();
		this.parentID= source.readString();
		this.radioShowMd= source.readString();
		this.res=source.readParcelable(Res.class.getClassLoader());
		this.restricted=  source.readByte() == 0;
		this.serviceID= source.readString();
		this.streamContent= source.readString();
		this.title= source.readString();
		this.audioUrl=source.readString();
		this.isFavorite = source.readByte() == 0;
		this.isRecommand = source.readByte() == 0;
		
		this.canAddToFavorites = source.readByte() == 0;
	}


	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getServiceID() {
		return serviceID;
	}

	public void setServiceID(String serviceID) {
		this.serviceID = serviceID;
	}

	public String getItemID() {
		return itemID;
	}

	public void setItemID(String itemID) {
		this.itemID = itemID;
	}

	public String getParentID() {
		return parentID;
	}

	public void setParentID(String parentID) {
		this.parentID = parentID;
	}

	public boolean isRestricted() {
		return restricted;
	}

	public void setRestricted(boolean restricted) {
		this.restricted = restricted;
	}

	public Res getRes() {
		return res;
	}

	public void setRes(Res res) {
		this.res = res;
	}

	public String getStreamContent() {
		return streamContent;
	}

	public void setStreamContent(String streamContent) {
		this.streamContent = streamContent;
	}

	public String getRadioShowMd() {
		return radioShowMd;
	}

	public void setRadioShowMd(String radioShowMd) {
		this.radioShowMd = radioShowMd;
	}

	public String getAlbumArtURI() {
		return albumArtURI;
	}

	public void setAlbumArtURI(String albumArtURI) {
		this.albumArtURI = albumArtURI;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getObjectClass() {
		return objectClass;
	}

	public void setObjectClass(String objectClass) {
		this.objectClass = objectClass;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public String getAlbum() {
		return album;
	}

	public void setAlbum(String album) {
		this.album = album;
	}

	public String getLyricURI() {
		return lyricURI;
	}

	public void setLyricURI(String lyricURI) {
		this.lyricURI = lyricURI;
	}

	public String getArtist() {
		return artist;
	}

	public void setArtist(String artist) {
		this.artist = artist;
	}

	public boolean isAutoAdd() {
		return isAutoAdd;
	}

	public void setAutoAdd(boolean isAutoAdd) {
		this.isAutoAdd = isAutoAdd;
	}

	public String getAudioUrl() {
		return audioUrl;
	}

	public void setAudioUrl(String audioUrl) {
		this.audioUrl = audioUrl;
	}

	public boolean isFavorite() {
		return isFavorite;
	}

	public void setFavorite(boolean isFavorite) {
		this.isFavorite = isFavorite;
	}

	public boolean isRecommand() {
		return isRecommand;
	}

	public void setRecommand(boolean isRecommand) {
		this.isRecommand = isRecommand;
	}

	public boolean isCanAddToFavorites() {
		return canAddToFavorites;
	}

	public void setCanAddToFavorites(boolean canAddToFavorites) {
		this.canAddToFavorites = canAddToFavorites;
	}


	public static class Res implements Parcelable{
		private String protocolInfo;
		private String duration;
		private String value;

		public Res(){}
		
		public Res(Parcel source) {
			this.duration = source.readString();
			this.protocolInfo = source.readString();
			this.value = source.readString();
		}

		public String getProtocolInfo() {
			return protocolInfo;
		}

		public void setProtocolInfo(String protocolInfo) {
			this.protocolInfo = protocolInfo;
		}

		public String getDuration() {
			return duration;
		}

		public void setDuration(String duration) {
			this.duration = duration;
		}

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		@Override
		public int describeContents() {
			return 0;
		}

		@Override
		public void writeToParcel(Parcel dest, int flags) {
			
			dest.writeString(this.duration);
			dest.writeString(this.protocolInfo);
			dest.writeString(this.value);
		}
		
		public static final Parcelable.Creator<Res> CREATOR = new Parcelable.Creator<Res>() {

			@Override
			public Res createFromParcel(Parcel source) {
				return new Res(source);
			}

			@Override
			public Res[] newArray(int size) {
				return new Res[size];
			}
		};

	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(this.album);
		dest.writeString(this.albumArtURI);
		dest.writeString(this.artist);
		dest.writeString(this.creator);
		dest.writeString(this.id);
		dest.writeByte((byte)(this.isAutoAdd ? 0:1));//if isAutoAdd == true, byte == 0 
		dest.writeString(this.itemID);
		dest.writeString(this.lyricURI);
		dest.writeString(this.objectClass);
		dest.writeString(this.parentID);
		dest.writeString(this.radioShowMd);
		dest.writeParcelable(this.res, flags);
		dest.writeByte((byte)(this.restricted ? 0:1));//if restricted == true, byte == 0 
		dest.writeString(this.serviceID);
		dest.writeString(this.streamContent);
		dest.writeString(this.title);
		dest.writeString(audioUrl);
		dest.writeByte((byte)(this.isFavorite ? 0:1));//if isAutoAdd == true, byte == 0 
		dest.writeByte((byte)(this.isRecommand ? 0:1));
		dest.writeByte((byte)(this.canAddToFavorites ? 0:1));//if isAutoAdd == true, byte == 0 
	}
	
	public static final Parcelable.Creator<Metadata> CREATOR = new Parcelable.Creator<Metadata>() {

		@Override
		public Metadata createFromParcel(Parcel source) {
			return new Metadata(source);
		}

		@Override
		public Metadata[] newArray(int size) {
			return new Metadata[size];
		}
	};

	@Override
	public String toString() {
		return "Metadata [id=" + id + ", serviceID=" + serviceID + ", itemID="
				+ itemID + ", parentID=" + parentID + ", albumArtURI="
				+ albumArtURI + ", title=" + title + ", album=" + album
				+ ", artist=" + artist + ", isFavorite=" + isFavorite + ",audioUrl="+audioUrl+"]";
	}
}
